package com.hllxd.hism.star.basic.service.service;

import com.alibaba.fastjson.JSON;
import com.hllxd.hism.star.basic.service.dao.mapper.mis.KpiDetailMapper;
import com.hllxd.hism.star.basic.service.model.metric.KpiDetailEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xiyong.lxy
 * @date 2020-10-12 16:51
 */
@Slf4j
@Service("kpiDetailService")
public class KpiDetailServiceImpl implements KpiDetailService {

    @Autowired
    private KpiDetailMapper metricKpiDetailMapper;


    @Override public KpiDetailEntity getKpiDetail(Long id) {
        return metricKpiDetailMapper.getKpiDetail(id);
    }

    @Override
    public Long setKpiDetail(KpiDetailEntity entity) {
        log.info("set param: {}", JSON.toJSONString(entity));
        if(entity.id==null || entity.id==0) {
            log.info("will insert entity.");
            return metricKpiDetailMapper.insertKpiDetail(entity);
        } else {
            log.info("will update entity.");
            return metricKpiDetailMapper.updateKpiDetail(entity);
        }
    }

    @Override
    public List<KpiDetailEntity> listKpiDetail(String kpiId) {

        return metricKpiDetailMapper.listKpiDetail(kpiId);
    }
    
    @Override
    public Boolean deleteKpiDetail(String ids) {
        return metricKpiDetailMapper.deleteKpiDetail(ids);
    }
}
